/**
 * @file    app_sox.c
 * @brief   用户任务-SOX算法
 * @author  Liuwei
 * @version 1.0.1
 * @date    2023-05-03
 * 
 * @copyright Copyright (c) 2023 JBD-Energy Storage Technology Co. LTD
 * 
 * @par 修改日志:
 * <table>
 * <tr><th>Date       <th>Version   <th>Author   <th>Description
 * <tr><td>2023-05-03 <td>1.0.1     <td>Liuwei   <td>首次创建
 * </table>
 */

/* includes ------------------------------------------------------------------*/
#include "app_sox.h"
#include "FreeRTOS.h"
#include "task.h"
#include "soc_calc.h"
#include "sop_calc.h"
#include "soh_calc.h"
#include "app_monitor.h"

/* macro/define --------------------------------------------------------------*/
#define APP_CLAC_SOX_TASK_CYCLE             (100) 

/* typedef -------------------------------------------------------------------*/

/* local functions -----------------------------------------------------------*/

/* static variables ----------------------------------------------------------*/

/* global variables ----------------------------------------------------------*/

/** ------------------------------------------------------------------------- *
  *                             Global function
 ** ------------------------------------------------------------------------- */
/**
 * @brief CAN通信任务
*/
void vCalcSOXTask(void *pvParameters)
{
	uint32_t task_cycle = 0;
	
    portTickType xLastExecutionTime;

    xLastExecutionTime = xTaskGetTickCount();

	task_run_reset(TASK_ID_SOX);
	
    while(1)
    {
		task_cycle = task_get_cycle(TASK_ID_SOX);
		if(task_cycle > 50 * APP_CLAC_SOX_TASK_CYCLE)
			task_cycle = APP_CLAC_SOX_TASK_CYCLE;
			
	    soc_calc(task_cycle);

	    sop_calc(task_cycle);

		soh_calc();
		
        task_run_count(TASK_ID_SOX);
        
        vTaskDelayUntil( &xLastExecutionTime, APP_CLAC_SOX_TASK_CYCLE );
    }
}

/** ------------------------------------------------------------------------- *
  *                              Local function
 ** ------------------------------------------------------------------------- */
 
/********** Copyright (c) 2023 JBD-Energy Storage Technology Co. LTD *********/


